<?php
defined('_JEXEC') or die;

class AppcategorysViewAppcategorys extends JViewLegacy
{
	protected $items;
	protected $pagination;
	protected $state;

	public function display($tpl = null)
	{
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');

		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}
		 	
		$this->addToolbar();
		parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @since	1.6
	 */
	protected function addToolbar()
	{
		$canDo	= AppcategorysHelper::getActions($this->state->get('filter.category_id'));
		$user		= JFactory::getUser();
 

		if ($canDo->get('core.create') || (count($user->getAuthorisedCategories('com_appcategorys', 'core.create'))) > 0 ) {
			JToolBarHelper::addNew('appcategory.add');
		}

		if (($canDo->get('core.edit')) || ($canDo->get('core.edit.own'))) {
			JToolBarHelper::editList('appcategory.edit');
		}

		if ($canDo->get('core.edit.state')) {
			JToolBarHelper::divider();
			JToolBarHelper::publish('appcategorys.publish', 'JTOOLBAR_PUBLISH', true);
			JToolBarHelper::unpublish('appcategorys.unpublish', 'JTOOLBAR_UNPUBLISH', true);
			//JToolBarHelper::custom('appcategorys.featured', 'featured.png', 'featured_f2.png', 'JFEATURED', true);
			JToolBarHelper::divider();
		//	JToolBarHelper::archiveList('appcategorys.archive');
			JToolBarHelper::checkin('appcategorys.checkin');
		}

		if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
			JToolBarHelper::deleteList('', 'appcategorys.delete', 'JTOOLBAR_EMPTY_TRASH');
			JToolBarHelper::divider();
		}
		elseif ($canDo->get('core.edit.state')) {
			JToolBarHelper::trash('appcategorys.trash');
			JToolBarHelper::divider();
		}

		if ($canDo->get('core.admin')) {
			JToolBarHelper::preferences('com_appcategorys');
			JToolBarHelper::divider();
		}

	}
}
